package com.gao.sentinel.common;

/**
 * 统一结果返回
 * Code码、Info描述
 */
public class Result {

    private String code;
    private String info;

    public Result(String code, String info) {
        this.code = code;
        this.info = info;
    }

    public static Result result(String code, String info) {
        return new Result(code, info);
    }

    public static Result result(Constants.ResponseCode code) {
        return new Result(code.getCode(), code.getInfo());
    }

    public static Result result(Constants.ResponseCode code, String info) {
        return new Result(code.getCode(), info);
    }

    public static Result result(Constants.ResponseCode code, Constants.ResponseCode info) {
        return new Result(code.getCode(), info.getInfo());
    }

    public static Result successResult() {
        return new Result(Constants.ResponseCode.SUCCESS.getCode(), Constants.ResponseCode.SUCCESS.getInfo());
    }

    public static Result errorResult() {
        return new Result(Constants.ResponseCode.UN_ERROR.getCode(), Constants.ResponseCode.UN_ERROR.getInfo());
    }

    public static Result errorResult(String info) {
        return new Result(Constants.ResponseCode.UN_ERROR.getCode(), info);
    }


    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }
}
